const formatTime = date => {
    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()

    return `${[year, month, day].map(formatNumber).join('-')} ${[hour, minute, second].map(formatNumber).join(':')}`
}

const formatNumber = n => {
    n = n.toString()
    return n[1] ? n : `0${n}`
}
// 92b3da87233944a286b6ce85287dd556
// const baseUrl = "http://106.55.106.183:8082"
const baseUrl = "https://wechat.lovegcu.xyz"
const xxtUrl ="https://xxt.lovegcu.xyz"
const javaUrl="https://www.lovegcu.xyz"
const qiangguoUrl = "https://qwer.lovegcu.xyz"
const isHaveToken = Boolean => {
    console.log(wx.getStorageSync('token'))
    if (wx.getStorageSync('token')) {
        wx.showToast({
            title: '已登录',
            duration: 500,
            icon: "success",
        })
        return true
    } else {
        wx.showToast({
            title: '未登录',
            duration: 500,
            icon: "loading",
        })
        return false
    }
}
const isHaveLogin = Boolean => {
    console.log("isHaveLogin",wx.getStorageSync('userInfo'))
    if (wx.getStorageSync('userInfo')) {
        wx.showToast({
            title: '已登录',
            duration: 500,
            icon: "success",
        })
        return true
    } else {
        wx.showToast({
            title: '未登录',
            duration: 500,
            icon: "loading",
        })
        return false
    }
}

const isLogin = () => {
    console.log("login",wx.getStorageSync('login'))
    if (wx.getStorageSync('login')) {
        wx.showToast({
            title: '已登录',
            duration: 500,
            icon: "success",
        })
        return true
    } else {
        wx.showToast({
            title: '未登录',
            duration: 500,
            icon: "loading",
        })
        return false
    }
}

module.exports = {
    formatTime,
    baseUrl,
    isHaveToken,
    isHaveLogin,
    xxtUrl,
    javaUrl,
    qiangguoUrl,
    isLogin
}